package gdonly.top.signin.business;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import org.json.JSONException;

import java.util.HashMap;
import java.util.List;

import gdonly.top.signin.R;
import gdonly.top.signin.utils.JsonUtil;
import gdonly.top.signin.widgets.ShowRecordsByCourseAdapter;

/**
 * Created by zhuzhuxia on 2017/5/14.
 */
public class QueryRecordsByCourseActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    private TextView title;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_queryrecordsbycourse);
        initViews();

    }
    private void initViews(){

        recyclerView= (RecyclerView) findViewById(R.id.recordsbycourse);
        title = (TextView) findViewById(R.id.title3);

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        String json = getIntent().getExtras().getString("result");
        String courseName = getIntent().getExtras().getString("course_name");
        String courseId = getIntent().getExtras().getString("course_id");
        title.setText("以下是" + courseName +"签到的结果");
        List<HashMap<String, Object>> data = null;
        try {
            data = JsonUtil.getRecordsByCourse(json);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        recyclerView.setAdapter(new ShowRecordsByCourseAdapter(data, QueryRecordsByCourseActivity.this, courseId));

    }
}
